<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>短信设置</title>
		<link href="css/table.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
		<script type="text/javascript">
			function selectUser(val){
				var url="getGrouphome.action?status="+val;
				openWindow(url,700,400);
			}
			function setValue(value,val){
				  var arr = eval(value);
				  var names = "";
				  var ids = "";
				  for(i=0;i<arr.length;i++){
				    ids =  ids + "," + arr[i].value;
				    names = names + "," + arr[i].name;
				  }
				  if(names.length>0){
				    names = names.substring(1);
				    ids =  ids.substring(1);
				  }
				  document.getElementById(val+"names").value=names;
				  document.getElementById(val+"ids").value=ids;
			}
			function getOldValue(val){
				  var ids=document.getElementById(val+"ids").value;
				  var names=document.getElementById(val+"names").value;
				    var array="";
				  if(ids!=''&&ids!='null'){
				  var idarray=ids.split(",");
				  var namearray=names.split(",");
				  for(var i=0;i<idarray.length;i++){
				  		if(i==0){
				  			array+="{\"value\":"+idarray[i]+",\"name\":\""+namearray[i]+"\"}";
				  		}else{
				  	      array+=",{\"value\":"+idarray[i]+",\"name\":\""+namearray[i]+"\"}";
				  	   } 
				  }
				  }
				  return array;
			}
		
		</script>
		<script type="text/javascript">
			function messageSet(){
				var name = $("#snames").val();
				if($.trim(name)==''||$.trim(name)=='null'){
					alert("适用范围不能为空！");
					return;
				}
				var number=$("#number").val();
				if($.trim(number)==''||$.trim(number)=='null'){
					alert("短信数量不能为空！");
					return;
				}
				if(number.length>5){
					alert("短信数量过大！");
					return;
				}
				if(/^[1-9]\d*$/.test(number)){
					document.messageForm.submit();
				}
				else{
					alert("短信数量必须是正整数！");
					return;
				}
			}
			function exit(){
				window.close();
			}
			function valid(){
				var keyCode = event.keyCode;
				if (keyCode == 13) {
					event.returnValue = false;
				} else {
					event.returnValue = true;
				}
			}
			
			

    
    		$(function() { 
    			var info=$("#info").html();
  			 	if(info=="保存成功！"){
  			 		closeMe();
  			 		window.opener.location="messageSet.action";
  			 	}
  			 	else{
  			 		return;
  			 	}
			}); 
			
			
			
			var secs =3; //倒计时的秒数 
			function closeMe(){ 
				for(var i=secs;i>=0;i--) 
				{ 
				window.setTimeout('doUpdate(' + i + ')', (secs-i) * 1000); 
				} 
			} 
			function doUpdate(num) 
			{ 
				document.getElementById('time').innerHTML = '将在'+num+'秒后自动关闭' ; 
				if(num == 0) { window.close(); } 
			} 
			
			
			
			
			

    
		</script>
		<script type="text/javascript" src="js/openwindow.js"></script>
	</head>

	<body>
		<table align="center" border="0" cellpadding="0" cellspacing="0"
			style="width: 98%;">
			<tbody>
				<tr>
					<td style="background: url('image/wsoa_window_002.gif');" width="1"></td>
					<td style="background: url('image/wsoa_window_002.gif');">
						<table border="0" cellpadding="0" cellspacing="0">
							<tbody>
								<tr>
									<td align="center"
										style="background: url('image/wsoa_window_002.gif');"
										width="10">
										<img src="image/center_19.gif">
									</td>
									<td align="center"
										style="background: url('image/wsoa_window_002.gif');"></td>
									<td>
										短信 &gt; 我的短信 &gt; 短信设置 &gt;
										<a href="messageSetAdd.action?status=a">添加</a>
									</td>
								</tr>
							</tbody>
						</table>
					</td>
					<td style="background: url('image/wsoa_window_002.gif');" width="1"></td>
				</tr>
				<tr>
					<td style="background: url('image/wsoa_window_010.gif');" width="1">
						&nbsp;
					</td>
					<td>

						<form action="messageSetAddSave.action" name="messageForm"
							method="post">
							<input type="hidden" name="messageSet.id"
								value="${messageSet.id }">
							<input type="hidden" name="messageSet.del"
								value="${messageSet.del }">
							<input type="hidden" name="status" value="${status }">
							<table class="table5">
								<tr>
									<td class="table5 bgcolor5">
										适用范围
									</td>
									<td class="table5">
										<textarea readonly="readonly" id="snames"
											style="height: 30px; width: 400px; border: #afcded double 2px;"
											name="messageSet.userNames">${messageSet.userNames }</textarea>
										<br />
										<a href="javascript:selectUser('s')">选择人员</a>
										<input type="hidden" id="sids" name="messageSet.userIds" value="${messageSet.userIds}">
									</td>
								</tr>
								<tr>
									<td class="table5 bgcolor5">
										短信数量
									</td>
									<td class="table5">
										<input id="number" type="text" style="width: 100px; border: #afcded double 2px;" name="messageSet.messageNumber" onkeydown="valid()" value="${messageSet.messageNumber }">
									</td>
								</tr>
								<tr>
									<td colspan="2" align="center">
									<input class="button_04" onclick="messageSet()" type="button" value="确定" />&nbsp;&nbsp;<input class="button_04" type="button" onclick="exit()" value="取消" />
										<br><br>
										<label id="info" style="color: red;">
											${info }
										</label>
									</td>
								</tr>
								<tr>
									<td colspan="2">
										<label id="time" style="color: red;"></label>
									</td>
								</tr>
							</table>
						</form>
					</td>
					<td style="background: url('image/wsoa_window_006.gif');" width="1">
						&nbsp;
					</td>
				</tr>
				<tr>
					<td height="1" width="1">
						<img src="image/wsoa_window_009.gif" height="16" width="14">
					</td>
					<td style="background: url('image/wsoa_window_008.gif');"
						height="1"></td>
					<td height="1" width="1">
						<img src="image/wsoa_window_007.gif" height="16" width="12">
					</td>
				</tr>
			</tbody>
		</table>
	</body>
</html>